package cn.tede.submarine;

import javax.swing.*;
import java.awt.*;

/**
战舰 1个
 */
public class Battleship extends SeaObject{
    private int life;           //命数，初始为5，定好的
    public Battleship(){
        super(66,26,270,124,20);
        life = 5;
    }
    public void move(){
        //不写这个
    }
    public ImageIcon getImage(){
        return Images.battleship;
    }
    //战舰发射深水炸弹
    public Bomb shoot(){
        return new Bomb(this.x,this.y);//this指代战舰，可以省略，加上更明确，深水炸弹的坐标就是战舰的坐标
    }
    public void moveLeft(){
        x -= speed;//x-向左
        if (x<=0){

        }
    }
    public void moveRight(){
        x += speed;//x+向右
    }
    //战舰增命
    public void addLife(int num){
        life += num;
    }
    //获取命数，直接返回life
    public int getLife(){
        return life;
    }

    //减命数
    public void subtractLife(){
        life--;
    }

}
